package com.freesky.biz.icbc.controller;

import com.freesky.biz.icbc.domain.*;
import com.freesky.biz.icbc.service.IFinanceReferrerService;
import com.freesky.biz.icbc.service.INanpingReferrerService;
import com.freesky.common.annotation.Log;
import com.freesky.common.core.controller.BaseController;
import com.freesky.common.core.domain.AjaxResult;
import com.freesky.common.core.page.TableDataInfo;
import com.freesky.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 南平合伙人
 */
@RestController
@RequestMapping("/icbc/nanping/referrer")
public class NanpingReferrerController extends BaseController {

    @Autowired
    private INanpingReferrerService nanpingReferrerService;


    @PreAuthorize("@ss.hasPermi('icbc:nanping:list')")
    @GetMapping("/list")
    public TableDataInfo list(TIcbcNanpingReferrer financeReferrer) {
        startPage();
        List<TIcbcNanpingReferrer> list = nanpingReferrerService.findList(financeReferrer);
        return getDataTable(list);
    }

    @Log(title = "工行南平众益", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('icbc:nanping:export')")
    @GetMapping("/export")
    public AjaxResult export(TIcbcNanpingReferrer financeReferrer,
                             HttpServletResponse response) {
        return nanpingReferrerService.exportFile(financeReferrer);
    }

    @PreAuthorize("@ss.hasPermi('icbc:nanping:list')")
    @GetMapping("/listCoupon")
    public TableDataInfo listCoupon(TIcbcNanpingReferrerCoupon referrerCoupon) {
        startPage();
        List<TIcbcNanpingReferrerCoupon> list = nanpingReferrerService.findReferrerCouponList(referrerCoupon);
        return getDataTable(list);
    }

    @Log(title = "工行南平众益", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('icbc:nanping:export')")
    @GetMapping("/exportCoupon")
    public AjaxResult exportCoupon(TIcbcNanpingReferrerCoupon referrerCoupon,
                             HttpServletResponse response) {
        return nanpingReferrerService.exportCouponFile(referrerCoupon);
    }

    @PreAuthorize("@ss.hasPermi('icbc:nanping:list')")
    @GetMapping("/listFuli")
    public TableDataInfo listFuli(TIcbcNanpingFuli icbcNanpingFuli) {
        startPage();
        List<TIcbcNanpingFuli> list = nanpingReferrerService.findNanpingFuli(icbcNanpingFuli);
        return getDataTable(list);
    }

    @Log(title = "工行南平众益", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('icbc:nanping:export')")
    @GetMapping("/exportFuli")
    public AjaxResult exportFuli(TIcbcNanpingFuli icbcNanpingFuli,
                             HttpServletResponse response) {
        return nanpingReferrerService.exportNanpingFuli(icbcNanpingFuli);
    }

}
